import { defineStore } from "pinia";
import { ref } from "vue";
export const useChatMenu = defineStore(
  "chatMenu",
  () => {
    const chatMenu = ref([
      {
        id: 1,
        name: "消息收藏夹",
        avatar: "/static/img/chat/testUserA.jpg",
        lastMessage: "image.jpeg",
        time: "Fri",
        unread: 0,
        isPinned: false,
        isMuted: false,
        x: 0,
      },
      {
        id: 2,
        name: "Test1",
        avatar: "/static/img/chat/testUserB.jpg",
        lastMessage: "GIF",
        time: "9/29",
        unread: 0,
        isPinned: false,
        isMuted: false,
        x: 0,
      },
      {
        id: 3,
        name: "Test2",
        avatar: "/static/img/chat/testUserA.jpg",
        lastMessage: "Let's choose the first option",
        time: "Sun",
        unread: 0,
        isPinned: false,
        isMuted: false,
        x: 0,
      },
      {
        id: 4,
        name: "Test3",
        avatar: "/static/img/chat/testUserA.jpg",
        lastMessage: "GIF, Suggested by @alex_21",
        time: "10:42",
        unread: 0,
        isPinned: true,
        isMuted: true,
        x: 0,
      },
    ]);
    const chatMenuIndex = ref(0);
    function changeChatMenuIndex(index) {
      chatMenuIndex.value = index;
    }
    function changeChatMenu(data) {
      chatMenu.value = data;
      // console.log("chatMenu-change", chatMenu.value);
    }
    return {
      chatMenu,
      chatMenuIndex,
      changeChatMenuIndex,
      changeChatMenu,
    };
  },
  {
    persist: {
      paths: ["chatMenu"],
    },
  }
);
